home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / pseudoDoc / ExampleHeaders / CFArray.h next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  31.7 KB  |  691 lines

  1. /*    CFArray.h
  2.     Copyright 1998-1999, Apple Computer, Inc. All rights reserved.
  3. */
  4.  
  5. /* NOTE:  This file is expressly for use with HeaderDoc, for testing purposes.  It is not the current CFArray.h file! */
  6.  
  7. /*!
  8.     @header CFArray
  9.     CFArray implements an ordered, compact container of pointer-sized
  10.     values. Values are accessed via integer keys (indices), from the
  11.     range 0 to N-1, where N is the number of values in the array when
  12.     an operation is performed. The array is said to be "compact" because
  13.     deleted or inserted values do not leave a gap in the key space --
  14.     the values with higher-numbered indices have their indices
  15.     renumbered lower (or higher, in the case of insertion) so that the
  16.     set of valid indices is always in the integer range [0, N-1]. Thus,
  17.     the index to access a particular value in the array may change over
  18.     time as other values are inserted into or deleted from the array.
  19.  
  20.     Arrays come in two flavors, immutable, which cannot have values
  21.     added to them or removed from them after the array is created, and
  22.     mutable, to which you can add values or from which remove values.
  23.     Mutable arrays have two subflavors, fixed-capacity, for which there
  24.     is a maximum number set at creation time of values which can be put
  25.     into the array, and variable capacity, which can have an unlimited
  26.     number of values (or rather, limited only by constraints external
  27.     to CFArray, like the amount of available memory). Fixed-capacity
  28.     arrays can be somewhat higher performing, if you can put a definate
  29.     upper limit on the number of values that might be put into the
  30.     array.
  31.  
  32.     As with all CoreFoundation collection types, arrays maintain hard
  33.     references on the values you put in them, but the retaining and
  34.     releasing functions are user-defined callbacks that can actually do
  35.     whatever the user wants (for example, nothing).
  36.  
  37.     Computational Complexity
  38.     The access time for a value in the array is guaranteed to be at
  39.     worst O(lg N) for any implementation, current and future, but will
  40.     often be O(1) (constant time). Linear search operations similarly
  41.     have a worst case complexity of O(N*lg N), though typically the
  42.     bounds will be tighter, and so on. Insertion or deletion operations
  43.     will typically be linear in the number of values in the array, but
  44.     may be O(N*lg N) clearly in the worst case in some implementations.
  45.     There are no favored positions within the array for performance;
  46.     that is, it is not necessarily faster access values with low
  47.     indices, or to insert or delete values with high indices, or
  48.     whatever.
  49. */
  50.  
  51. #if !defined(__COREFOUNDATION_CFARRAY__)
  52. #define __COREFOUNDATION_CFARRAY__ 1
  53.  
  54. #include <CoreFoundation/CFBase.h>
  55.  
  56. #if defined(__cplusplus)
  57. extern "C" {
  58. #endif
  59.  
  60. /*!
  61.     @typedef CFArrayCallBacks
  62.     Structure containing the callbacks of a CFArray.
  63.     @field version The version number of the structure type being passed
  64.         in as a parameter to the CFArray creation functions. This
  65.         structure is version 0.
  66.     @field retain The callback used to add a retain for the array on
  67.         values as they are put into the array. This callback returns
  68.         the value to store in the array, which is usually the value
  69.         parameter passed to this callback, but may be a different
  70.         value if a different value should be stored in the array.
  71.         The array's allocator is passed as the first argument.
  72.     @field release The callback used to remove a retain previously added
  73.         for the array from values as they are removed from the
  74.         array. The array's allocator is passed as the first
  75.         argument.
  76.     @field copyDescription The callback used to create a descriptive
  77.         string representation of each value in the array. This is
  78.         used by the CFCopyDescription() function.
  79.     @field equal The callback used to compare values in the array for
  80.         equality for some operations.
  81. */
  82. typedef const void *    (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
  83. typedef void        (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
  84. typedef CFStringRef    (*CFArrayCopyDescriptionCallBack)(const void *value);
  85. typedef Boolean        (*CFArrayEqualCallBack)(const void *value1, const void *value2);
  86. typedef struct {
  87.     CFIndex                version;
  88.     CFArrayRetainCallBack        retain;
  89.     CFArrayReleaseCallBack        release;
  90.     CFArrayCopyDescriptionCallBack    copyDescription;
  91.     CFArrayEqualCallBack        equal;
  92. } CFArrayCallBacks;
  93.  
  94. /*!
  95.     @const kCFTypeArrayCallBacks
  96.     @discussion Predefined CFArrayCallBacks structure containing a set of callbacks
  97.     appropriate for use when the values in a CFArray are all CFTypes.
  98. */
  99. CF_EXPORT
  100. const CFArrayCallBacks kCFTypeArrayCallBacks;
  101.  
  102. /*!
  103.     @typedef CFArrayApplierFunction
  104.     Type of the callback function used by the apply functions of
  105.         CFArrays.
  106.     @param val The current value from the array.
  107.     @param context The user-defined context parameter given to the apply
  108.         function.
  109. */
  110. typedef void (*CFArrayApplierFunction)(const void *value, void *context);
  111.  
  112. /*!
  113.     @typedef CFArrayRef
  114.     This is the type of a reference to immutable CFArrays.
  115. */
  116. typedef const struct __CFArray * CFArrayRef;
  117.  
  118. /*!
  119.     @typedef CFMutableArrayRef
  120.     This is the type of a reference to mutable CFArrays.
  121. */
  122. typedef struct __CFArray * CFMutableArrayRef;
  123.  
  124. /*!
  125.     @function CFArrayGetTypeID
  126.     Returns the type identifier of all CFArray instances.
  127. */
  128. CF_EXPORT
  129. CFTypeID CFArrayGetTypeID(void);
  130.  
  131. /*!
  132.     @function CFArrayCreate
  133.     Creates a new immutable array with the given values.
  134.     @param allocator The CFAllocator which should be used to allocate
  135.         memory for the array and its storage for values. This
  136.         parameter may be NULL in which case the current default
  137.         CFAllocator is used. If this reference is not a valid
  138.         CFAllocator, the behavior is undefined.
  139.     @param values A C array of the pointer-sized values to be in the
  140.         array. The values in the array are ordered in the same order
  141.         in which they appear in this C array. This parameter may be
  142.         NULL if the numValues parameter is 0. This C array is not
  143.         changed or freed by this function. If this parameter is not
  144.         a valid pointer to a C array of at least numValues pointers,
  145.         the behavior is undefined.
  146.     @param numValues The number of values to copy from the values C
  147.         array into the CFArray. This number will be the count of the
  148.         array.
  149.         If this parameter is negative, or greater than the number of
  150.         values actually in the values C array, the behavior is
  151.         undefined.
  152.     @param callBacks A pointer to a CFArrayCallBacks structure
  153.         initialized with the callbacks for the array to use on each
  154.         value in the array. The retain callback will be used within
  155.         this function, for example, to retain all of the new values
  156.         from the values C array. A copy of the contents of the
  157.         callbacks structure is made, so that a pointer to a
  158.         structure on the stack can be passed in, or can be reused
  159.         for multiple array creations. If the version field of this
  160.         callbacks structure is not one of the defined ones for
  161.         CFArray, the behavior is undefined. The retain field may be
  162.         NULL, in which case the CFArray will do nothing to add a
  163.         retain to the contained values for the array. The release
  164.         field may be NULL, in which case the CFArray will do nothing
  165.         to remove the array's retain (if any) on the values when the
  166.         array is destroyed. If the copyDescription field is NULL,
  167.         the array will create a simple description for the value. If
  168.         the equal field is NULL, the array will use pointer equality
  169.         to test for equality of values. This callbacks parameter
  170.         itself may be NULL, which is treated as if a valid structure
  171.         of version 0 with all fields NULL had been passed in.
  172.         Otherwise, if any of the fields are not valid pointers to
  173.         functions of the correct type, or this parameter is not a
  174.         valid pointer to a  CFArrayCallBacks callbacks structure,
  175.         the behavior is undefined. If any of the values put into the
  176.         array is not one understood by one of the callback functions
  177.         the behavior when that callback function is used is
  178.         undefined.
  179.     @result A reference to the new immutable CFArray.
  180. */
  181. CF_EXPORT
  182. CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
  183.  
  184. /*!
  185.     @function CFArrayCreateCopy
  186.     Creates a new immutable array with the values from the given array.
  187.     @param allocator The CFAllocator which should be used to allocate
  188.         memory for the array and its storage for values. This
  189.         parameter may be NULL in which case the current default
  190.         CFAllocator is used. If this reference is not a valid
  191.         CFAllocator, the behavior is undefined.
  192.     @param theArray The array which is to be copied. The values from the
  193.         array are copied as pointers into the new array (that is,
  194.         the values themselves are copied, not that which the values
  195.         point to, if anything). However, the values are also
  196.         retained by the new array. The count of the new array will
  197.         be the same as the given array. The new array uses the same
  198.         callbacks as the array to be copied. If this parameter is
  199.         not a valid CFArray, the behavior is undefined.
  200.     @result A reference to the new immutable CFArray.
  201. */
  202. CF_EXPORT
  203. CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray);
  204.  
  205. /*!
  206.     @function CFArrayCreateMutable
  207.     Creates a new empty mutable array.
  208.     @param allocator The CFAllocator which should be used to allocate
  209.         memory for the array and its storage for values. This
  210.         parameter may be NULL in which case the current default
  211.         CFAllocator is used. If this reference is not a valid
  212.         CFAllocator, the behavior is undefined.
  213.     @param capacity The maximum number of values that can be contained
  214.         by the CFArray. The array starts empty, and can grow to this
  215.         number of values (and it can have less). If this parameter
  216.         is 0, the array's maximum capacity is unlimited (or rather,
  217.         only limited by address space and available memory
  218.         constraints). If this parameter is negative, the behavior is
  219.         undefined.
  220.     @param callBacks A pointer to a CFArrayCallBacks structure
  221.         initialized with the callbacks for the array to use on each
  222.         value in the array. A copy of the contents of the
  223.         callbacks structure is made, so that a pointer to a
  224.         structure on the stack can be passed in, or can be reused
  225.         for multiple array creations. If the version field of this
  226.         callbacks structure is not one of the defined ones for
  227.         CFArray, the behavior is undefined. The retain field may be
  228.         NULL, in which case the CFArray will do nothing to add a
  229.         retain to the contained values for the array. The release
  230.         field may be NULL, in which case the CFArray will do nothing
  231.         to remove the arrays retain (if any) on the values when the
  232.         array is destroyed. If the copyDescription field is NULL,
  233.         the array will create a simple description for the value. If
  234.         the equal field is NULL, the array will use pointer equality
  235.         to test for equality of values. This callbacks parameter
  236.         itself may be NULL, which is treated as if a valid structure
  237.         of version 0 with all fields NULL had been passed in.
  238.         Otherwise, if any of the fields are not valid pointers to
  239.         functions of the correct type, or this parameter is not a
  240.         valid pointer to a  CFArrayCallBacks callbacks structure,
  241.         the behavior is undefined. If any of the values put into the
  242.         array is not one understood by one of the callback functions
  243.         the behavior when that callback function is used is
  244.         undefined.
  245.     @result A reference to the new mutable CFArray.
  246. */
  247. CF_EXPORT
  248. CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
  249.  
  250. /*!
  251.     @function CFArrayCreateMutableCopy
  252.     Creates a new mutable array with the values from the given array.
  253.     @param allocator The CFAllocator which should be used to allocate
  254.         memory for the array and its storage for values. This
  255.         parameter may be NULL in which case the current default
  256.         CFAllocator is used. If this reference is not a valid
  257.         CFAllocator, the behavior is undefined.
  258.     @param capacity The maximum number of values that can be contained
  259.         by the CFArray. The array starts empty, and can grow to this
  260.         number of values (and it can have less). If this parameter
  261.         is 0, the array's maximum capacity is unlimited (or rather,
  262.         only limited by address space and available memory
  263.         constraints). This parameter must be greater than or equal
  264.         to the count of the array which is to be copied, or the
  265.         behavior is undefined. If this parameter is negative, the
  266.         behavior is undefined.
  267.     @param theArray The array which is to be copied. The values from the
  268.         array are copied as pointers into the new array (that is,
  269.         the values themselves are copied, not that which the values
  270.         point to, if anything). However, the values are also
  271.         retained by the new array. The count of the new array will
  272.         be the same as the given array. The new array uses the same
  273.         callbacks as the array to be copied. If this parameter is
  274.         not a valid CFArray, the behavior is undefined.
  275.     @result A reference to the new mutable CFArray.
  276. */
  277. CF_EXPORT 
  278. CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef theArray);
  279.  
  280. /*!
  281.     @function CFArrayGetCount
  282.     Returns the number of values currently in the array.
  283.     @param theArray The array to be queried. If this parameter is not a valid
  284.         CFArray, the behavior is undefined.
  285.     @result The number of values in the array.
  286. */
  287. CF_EXPORT
  288. CFIndex CFArrayGetCount(CFArrayRef theArray);
  289.  
  290. /*!
  291.     @function CFArrayGetCountOfValue
  292.     Counts the number of times the given value occurs in the array.
  293.     @param theArray The array to be searched. If this parameter is not a
  294.         valid CFArray, the behavior is undefined.
  295.     @param range The range within the array to search. If the range
  296.         location or end point (defined by the location plus length
  297.         minus 1) are outside the index space of the array (0 to
  298.         N-1 inclusive, where N is the count of the array), the
  299.         behavior is undefined. If the range length is negative, the
  300.         behavior is undefined. The range may be empty (length 0).
  301.     @param value The value for which to find matches in the array. The
  302.         equal() callback provided when the array was created is
  303.         used to compare. If the equal() callback was NULL, pointer
  304.         equality (in C, ==) is used. If value, or any of the values
  305.         in the array, are not understood by the equal() callback,
  306.         the behavior is undefined.
  307.     @result The number of times the given value occurs in the array,
  308.         within the specified range.
  309. */
  310. CF_EXPORT
  311. CFIndex CFArrayGetCountOfValue(CFArrayRef theArray, CFRange range, const void *value);
  312.  
  313. /*!
  314.     @function CFArrayContainsValue
  315.     Reports whether or not the value is in the array.
  316.     @param theArray The array to be searched. If this parameter is not a
  317.         valid CFArray, the behavior is undefined.
  318.     @param range The range within the array to search. If the range
  319.         location or end point (defined by the location plus length
  320.         minus 1) are outside the index space of the array (0 to
  321.         N-1 inclusive, where N is the count of the array), the
  322.         behavior is undefined. If the range length is negative, the
  323.         behavior is undefined. The range may be empty (length 0).
  324.     @param value The value for which to find matches in the array. The
  325.         equal() callback provided when the array was created is
  326.         used to compare. If the equal() callback was NULL, pointer
  327.         equality (in C, ==) is used. If value, or any of the values
  328.         in the array, are not understood by the equal() callback,
  329.         the behavior is undefined.
  330.     @result TRUE, if the value is in the specified range of the array,
  331.         otherwise FALSE.
  332. */
  333. CF_EXPORT
  334. Boolean CFArrayContainsValue(CFArrayRef theArray, CFRange range, const void *value);
  335.  
  336. /*!
  337.     @function CFArrayGetValueAtIndex
  338.     Retrieves the value at the given index.
  339.     @param theArray The array to be queried. If this parameter is not a
  340.         valid CFArray, the behavior is undefined.
  341.     @param idx The index of the value to retrieve. If the index is
  342.         outside the index space of the array (0 to N-1 inclusive,
  343.         where N is the count of the array), the behavior is
  344.         undefined.
  345.     @result The value with the given index in the array.
  346. */
  347. CF_EXPORT
  348. const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
  349.  
  350. /*!
  351.     @function CFArrayGetValues
  352.     Fills the buffer with values from the array.
  353.     @param theArray The array to be queried. If this parameter is not a
  354.         valid CFArray, the behavior is undefined.
  355.     @param range The range of values within the array to retrieve. If
  356.         the range location or end point (defined by the location
  357.         plus length minus 1) are outside the index space of the
  358.         array (0 to N-1 inclusive, where N is the count of the
  359.         array), the behavior is undefined. If the range length is
  360.         negative, the behavior is undefined. The range may be empty
  361.         (length 0), in which case no values are put into the buffer.
  362.     @param values A C array of pointer-sized values to be filled with
  363.         values from the array. The values in the C array are ordered
  364.         in the same order in which they appear in the array. If this
  365.         parameter is not a valid pointer to a C array of at least
  366.         range.length pointers, the behavior is undefined.
  367. */
  368. CF_EXPORT
  369. void CFArrayGetValues(CFArrayRef theArray, CFRange range, const void **values);
  370.  
  371. /*!
  372.     @function CFArrayApplyFunction
  373.     Calls a function once for each value in the array.
  374.     @param theArray The array to be operated upon. If this parameter is not
  375.         a valid CFArray, the behavior is undefined.
  376.     @param range The range of values within the array to which to apply
  377.         the function. If the range location or end point (defined by
  378.         the location plus length minus 1) are outside the index
  379.         space of the array (0 to N-1 inclusive, where N is the count
  380.         of the array), the behavior is undefined. If the range
  381.         length is negative, the behavior is undefined. The range may
  382.         be empty (length 0).
  383.     @param applier The callback function to call once for each value in
  384.         the given range in the array. If this parameter is not a
  385.         pointer to a function of the correct prototype, the behavior
  386.         is undefined. If there are values in the range which the
  387.         applier function does not expect or cannot properly apply
  388.         to, the behavior is undefined. 
  389.     @param context A pointer-sized user-defined value, which is passed
  390.         as the second parameter to the applier function, but is
  391.         otherwise unused by this function. If the context is not
  392.         what is expected by the applier function, the behavior is
  393.         undefined.
  394. */
  395. CF_EXPORT
  396. void CFArrayApplyFunction(CFArrayRef theArray, CFRange range, CFArrayApplierFunction applier, void *context);
  397.  
  398. /*!
  399.     @function CFArrayGetFirstIndexOfValue
  400.     Searches the array for the value.
  401.     @param theArray The array to be searched. If this parameter is not a
  402.         valid CFArray, the behavior is undefined.
  403.     @param range The range within the array to search. If the range
  404.         location or end point (defined by the location plus length
  405.         minus 1) are outside the index space of the array (0 to
  406.         N-1 inclusive, where N is the count of the array), the
  407.         behavior is undefined. If the range length is negative, the
  408.         behavior is undefined. The range may be empty (length 0).
  409.         The search progresses from the smallest index defined by
  410.         the range to the largest.
  411.     @param value The value for which to find a match in the array. The
  412.         equal() callback provided when the array was created is
  413.         used to compare. If the equal() callback was NULL, pointer
  414.         equality (in C, ==) is used. If value, or any of the values
  415.         in the array, are not understood by the equal() callback,
  416.         the behavior is undefined.
  417.     @result The lowest index of the matching values in the range, or -1
  418.         if no value in the range matched.
  419. */
  420. CF_EXPORT
  421. CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
  422.  
  423. /*!
  424.     @function CFArrayGetLastIndexOfValue
  425.     Searches the array for the value.
  426.     @param theArray The array to be searched. If this parameter is not a
  427.         valid CFArray, the behavior is undefined.
  428.     @param range The range within the array to search. If the range
  429.         location or end point (defined by the location plus length
  430.         minus 1) are outside the index space of the array (0 to
  431.         N-1 inclusive, where N is the count of the array), the
  432.         behavior is undefined. If the range length is negative, the
  433.         behavior is undefined. The range may be empty (length 0).
  434.         The search progresses from the largest index defined by the
  435.         range to the smallest.
  436.     @param value The value for which to find a match in the array. The
  437.         equal() callback provided when the array was created is
  438.         used to compare. If the equal() callback was NULL, pointer
  439.         equality (in C, ==) is used. If value, or any of the values
  440.         in the array, are not understood by the equal() callback,
  441.         the behavior is undefined.
  442.     @result The highest index of the matching values in the range, or -1
  443.         if no value in the range matched.
  444. */
  445. CF_EXPORT
  446. CFIndex CFArrayGetLastIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
  447.  
  448. /*!
  449.     @function CFArrayBSearchValues
  450.     Searches the array for the value using a binary search algorithm.
  451.     @param theArray The array to be searched. If this parameter is not a
  452.         valid CFArray, the behavior is undefined. If the array is
  453.         not sorted from least to greatest according to the
  454.         comparator function, the behavior is undefined.
  455.     @param range The range within the array to search. If the range
  456.         location or end point (defined by the location plus length
  457.         minus 1) are outside the index space of the array (0 to
  458.         N-1 inclusive, where N is the count of the array), the
  459.         behavior is undefined. If the range length is negative, the
  460.         behavior is undefined. The range may be empty (length 0).
  461.     @param value The value for which to find a match in the array. If
  462.         value, or any of the values in the array, are not understood
  463.         by the comparator callback, the behavior is undefined.
  464.     @param comparator The function with the comparator function type
  465.         signature which is used in the binary search operation to
  466.         compare values in the array with the given value. If this
  467.         parameter is not a pointer to a function of the correct
  468.         prototype, the behavior is undefined. If there are values
  469.         in the range which the comparator function does not expect
  470.         or cannot properly compare, the behavior is undefined.
  471.     @param context A pointer-sized user-defined value, which is passed
  472.         as the third parameter to the comparator function, but is
  473.         otherwise unused by this function. If the context is not
  474.         what is expected by the comparator function, the behavior is
  475.         undefined.
  476.     @result The return value is either 1) the index of a value that
  477.         matched, if the target value matches one or more in the
  478.         range, 2) greater than or equal to the end point of the
  479.         range, if the value is greater than all the values in the
  480.         range, or 3) the index of the value greater than the target
  481.         value, if the value lies between two of (or less than all
  482.         of) the values in the range.
  483. */
  484. CF_EXPORT
  485. CFIndex CFArrayBSearchValues(CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context);
  486.  
  487. /*!
  488.     @function CFArrayAppendValue
  489.     Adds the value to the array giving it the new largest index.
  490.     @param theArray The array to which the value is to be added. If this
  491.         parameter is not a valid mutable CFArray, the behavior is
  492.         undefined. If the array is a fixed-capacity array and it
  493.         is full before this operation, the behavior is undefined.
  494.     @param value The value to add to the array. The value is retained by
  495.         the array using the retain callback provided when the array
  496.         was created. If the value is not of the sort expected by the
  497.         retain callback, the behavior is undefined. The value is
  498.         assigned to the index one larger than the previous largest
  499.         index, and the count of the array is increased by one.
  500. */
  501. CF_EXPORT
  502. void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
  503.  
  504. /*!
  505.     @function CFArrayInsertValueAtIndex
  506.     Adds the value to the array giving it the given index.
  507.     @param theArray The array to which the value is to be added. If this
  508.         parameter is not a valid mutable CFArray, the behavior is
  509.         undefined. If the array is a fixed-capacity array and it
  510.         is full before this operation, the behavior is undefined.
  511.     @param idx The index to which to add the new value. If the index is
  512.         outside the index space of the array (0 to N inclusive,
  513.         where N is the count of the array before the operation), the
  514.         behavior is undefined. If the index is the same as N, this
  515.         function has the same effect as CFArrayAppendValue().
  516.     @param value The value to add to the array. The value is retained by
  517.         the array using the retain callback provided when the array
  518.         was created. If the value is not of the sort expected by the
  519.         retain callback, the behavior is undefined. The value is
  520.         assigned to the given index, and all values with equal and
  521.         larger indices have their indexes increased by one.
  522. */
  523. CF_EXPORT
  524. void CFArrayInsertValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
  525.  
  526. /*!
  527.     @function CFArraySetValueAtIndex
  528.     Changes the value with the given index in the array.
  529.     @param theArray The array in which the value is to be changed. If this
  530.         parameter is not a valid mutable CFArray, the behavior is
  531.         undefined. If the array is a fixed-capacity array and it
  532.         is full before this operation and the index is the same as
  533.         N, the behavior is undefined.
  534.     @param idx The index to which to set the new value. If the index is
  535.         outside the index space of the array (0 to N inclusive,
  536.         where N is the count of the array before the operation), the
  537.         behavior is undefined. If the index is the same as N, this
  538.         function has the same effect as CFArrayAppendValue().
  539.     @param value The value to set in the array. The value is retained by
  540.         the array using the retain callback provided when the array
  541.         was created, and the previous value with that index is
  542.         released. If the value is not of the sort expected by the
  543.         retain callback, the behavior is undefined. The indices of
  544.         other values is not affected.
  545. */
  546. CF_EXPORT
  547. void CFArraySetValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
  548.  
  549. /*!
  550.     @function CFArrayRemoveValueAtIndex
  551.     Removes the value with the given index from the array.
  552.     @param theArray The array from which the value is to be removed. If
  553.         this parameter is not a valid mutable CFArray, the behavior
  554.         is undefined.
  555.     @param idx The index from which to remove the value. If the index is
  556.         outside the index space of the array (0 to N-1 inclusive,
  557.         where N is the count of the array before the operation), the
  558.         behavior is undefined.
  559. */
  560. CF_EXPORT
  561. void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, CFIndex idx);
  562.  
  563. /*!
  564.     @function CFArrayRemoveAllValues
  565.     Removes all the values from the array, making it empty.
  566.     @param theArray The array from which all of the values are to be
  567.         removed. If this parameter is not a valid mutable CFArray,
  568.         the behavior is undefined.
  569. */
  570. CF_EXPORT
  571. void CFArrayRemoveAllValues(CFMutableArrayRef theArray);
  572.  
  573. /*!
  574.     @function CFArrayReplaceValues
  575.     Replaces a range of values in the array.
  576.     @param theArray The array from which all of the values are to be
  577.         removed. If this parameter is not a valid mutable CFArray,
  578.         the behavior is undefined.
  579.     @param range The range of values within the array to replace. If the
  580.         range location or end point (defined by the location plus
  581.         length minus 1) are outside the index space of the array (0
  582.         to N inclusive, where N is the count of the array), the
  583.         behavior is undefined. If the range length is negative, the
  584.         behavior is undefined. The range may be empty (length 0),
  585.         in which case the new values are merely inserted at the
  586.         range location.
  587.     @param newValues A C array of the pointer-sized values to be placed
  588.         into the array. The new values in the array are ordered in
  589.         the same order in which they appear in this C array. This
  590.         parameter may be NULL if the newCount parameter is 0. This
  591.         C array is not changed or freed by this function. If this
  592.         parameter is not a valid pointer to a C array of at least
  593.         newCount pointers, the behavior is undefined.
  594.     @param newCount The number of values to copy from the values C
  595.         array into the CFArray. If this parameter is different than
  596.         the range length, the excess newCount values will be
  597.         inserted after the range, or the excess range values will be
  598.         deleted. This parameter may be 0, in which case no new
  599.         values are replaced into the array and the values in the
  600.         range are simply removed. If this parameter is negative, or
  601.         greater than the number of values actually in the newValues
  602.         C array, the behavior is undefined.
  603. */
  604. CF_EXPORT
  605. void CFArrayReplaceValues(CFMutableArrayRef theArray, CFRange range, const void **newValues, CFIndex newCount);
  606.  
  607. /*!
  608.     @function CFArrayExchangeValuesAtIndices
  609.     Exchanges the values at two indices of the array.
  610.     @param theArray The array of which the values are to be swapped. If
  611.         this parameter is not a valid mutable CFArray, the behavior
  612.         is undefined.
  613.     @param idx1 The first index whose values should be swapped. If the
  614.         index is outside the index space of the array (0 to N-1
  615.         inclusive, where N is the count of the array before the
  616.         operation), the behavior is undefined.
  617.     @param idx2 The second index whose values should be swapped. If the
  618.         index is outside the index space of the array (0 to N-1
  619.         inclusive, where N is the count of the array before the
  620.         operation), the behavior is undefined.
  621. */
  622. CF_EXPORT
  623. void CFArrayExchangeValuesAtIndices(CFMutableArrayRef theArray, CFIndex idx1, CFIndex idx2);
  624.  
  625. /*!
  626.     @function CFArraySortValues
  627.     Sorts the values in the array using the given comparison function.
  628.     @param theArray The array whose values are to be sorted. If this
  629.         parameter is not a valid mutable CFArray, the behavior is
  630.         undefined.
  631.     @param range The range of values within the array to sort. If the
  632.         range location or end point (defined by the location plus
  633.         length minus 1) are outside the index space of the array (0
  634.         to N-1 inclusive, where N is the count of the array), the
  635.         behavior is undefined. If the range length is negative, the
  636.         behavior is undefined. The range may be empty (length 0).
  637.     @param comparator The function with the comparator function type
  638.         signature which is used in the sort operation to compare
  639.         values in the array with the given value. If this parameter
  640.         is not a pointer to a function of the correct prototype, the
  641.         the behavior is undefined. If there are values in the array
  642.         which the comparator function does not expect or cannot
  643.         properly compare, the behavior is undefined. The values in
  644.         the range are sorted from least to greatest according to
  645.         this function.
  646.     @param context A pointer-sized user-defined value, which is passed
  647.         as the third parameter to the comparator function, but is
  648.         otherwise unused by this function. If the context is not
  649.         what is expected by the comparator function, the behavior is
  650.         undefined.
  651. */
  652. CF_EXPORT
  653. void CFArraySortValues(CFMutableArrayRef theArray, CFRange range, CFComparatorFunction comparator, void *context);
  654.  
  655. /*!
  656.     @function CFArrayAppendArray
  657.     Adds the values from an array to another array.
  658.     @param theArray The array to which values from the otherArray are to
  659.         be added. If this parameter is not a valid mutable CFArray,
  660.         the behavior is undefined. If the array is a fixed-capacity
  661.         array and adding range.length values from the otherArray
  662.         exceeds the capacity of the array, the behavior is
  663.         undefined.
  664.     @param otherArray The array providing the values to be added to the
  665.         array. If this parameter is not a valid CFArray, the
  666.         behavior is undefined.
  667.     @param otherRange The range within the otherArray from which to add
  668.         the values to the array. If the range location or end point
  669.         (defined by the location plus length minus 1) are outside
  670.         the index space of the otherArray (0 to N-1 inclusive, where
  671.         N is the count of the otherArray), the behavior is
  672.         undefined. The new values are retained by the array using
  673.         the retain callback provided when the array was created. If
  674.         the values are not of the sort expected by the retain
  675.         callback, the behavior is undefined. The values are assigned
  676.         to the indices one larger than the previous largest index
  677.         in the array, and beyond, and the count of the array is
  678.         increased by range.length. The values are assigned new
  679.         indices in the array from smallest to largest index in the
  680.         order in which they appear in the otherArray.
  681. */
  682. CF_EXPORT
  683. void CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange);
  684.  
  685. #if defined(__cplusplus)
  686. }
  687. #endif
  688.  
  689. #endif /* ! __COREFOUNDATION_CFARRAY__ */
  690.  
  691.